Add PostHog storytelling v2 tracking for notebook usage flows. - #105
Merged
Conversation
Instrument upload, chat, dashboard navigation, and workspace lifecycle events with shared analytics context, tests, and GA4 alignment docs. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep official library and diagram changes from staging while preserving PostHog analytics instrumentation. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@kaiyu96 is attempting to deploy a commit to the Ontos AI Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds client-side PostHog analytics to Notebook, including initialization, event helpers, and UI instrumentation for key product actions.
Changes:
- Introduces a client-only PostHog wrapper (
src/lib/posthog.ts) plus app-level initialization viaPostHogProvider. - Instruments Notebook UX flows (uploads, chat, dashboard link, page views) with structured analytics context.
- Adds Vitest coverage for the new tracking hooks/components and documents event/parameter conventions.
Reviewed changes
Copilot reviewed 23 out of 25 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/providers/posthog-provider.tsx | Initializes PostHog on the client via a wrapper component. |
| src/lib/posthog.ts | Adds PostHog init + typed tracking helpers for Notebook events. |
| src/lib/posthog.test.ts | Tests PostHog enablement and identify/reset behaviors. |
| src/components/workspace-shell.tsx | Wires identify/reset, pageview tracking, and “first doc uploaded” tracking. |
| src/components/workspace-shell-layout.tsx | Threads analytics context + snapshot counts into panels and nav. |
| src/components/workspace-chat-workflow.ts | Tracks assistant question/answer success/failure + first question asked. |
| src/components/top-nav.tsx | Tracks dashboard link clicks and passes context metadata. |
| src/components/top-nav.test.tsx | Verifies dashboard click triggers tracking with expected payload. |
| src/components/sources-panel.tsx | Passes analytics context and source count snapshot into upload dialog. |
| src/components/source-upload-dialog.tsx | Tracks upload button clicks; passes context into upload workflow. |
| src/components/source-upload-dialog.test.tsx | Verifies upload-button click tracking is invoked. |
| src/components/source-upload-dialog-workflow.ts | Tracks upload success/failure with metadata and counts. |
| src/components/source-upload-dialog-workflow.test.ts | Verifies upload-completed tracking payload. |
| src/components/chunks-panel.tsx | Threads analytics props into empty-state upload flow. |
| src/components/chat-panel.tsx | Passes analytics + source counts into the chat composer. |
| src/components/chat-composer.tsx | Tracks question submission with thread + source metadata. |
| src/components/chat-composer.test.tsx | Verifies question-submitted tracking payload. |
| src/app/layout.tsx | Wraps app in PostHogProvider to ensure initialization. |
| package.json | Adds posthog-js dependency. |
| docs/posthog-notebook-tracking.md | Runbook for PostHog insights/dashboard setup. |
| docs/ga4-alignment.md | Documents GA4 alignment for event names/parameters. |
| README.md | Documents env vars and high-level event list and setup. |
| .env.local.example | Adds PostHog env var examples and notes. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use full page URLs, dedupe pageview tracking, rename the initializer component, and tighten analytics prop typing. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve chat-panel conflict by keeping PostHog analytics props and staging diagram creation updates. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
Update on follow-up itemsHi — I’ve pushed additional fixes to Code / conflicts
Checks still blocked (needs team action)
AskCould someone please:
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
staging(official library, diagram, chat updates) and resolve conflicts while preserving analytics instrumentation.Test plan
NEXT_PUBLIC_POSTHOG_KEYconfigurednotebook_upload_button_clicked,notebook_document_upload_completed/_failednotebook_assistant_question_submitted, answer completed/failed eventsnotebook_dashboard_link_clickedMade with Cursor